package com.summarecon.qualitycontrol;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.TextView;
import android.widget.Toast;
import com.summarecon.database.*;

public class LocationActivity extends Activity {
	GridView gridView;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
 		setContentView(R.layout.activity_location);
 		
		gridView = (GridView) findViewById(R.id.listLocation);
		
		DatabaseLocation dbLocation = new DatabaseLocation(LocationActivity.this);
		dbLocation.open();
		String[] data = dbLocation.getAllRowsAsArrays();
		dbLocation.close();
		Log.i("data", data.toString());
		
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,data);
		gridView.setAdapter(adapter);
 
		gridView.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View v,
				int position, long id) {
				Intent newActivity = new Intent(getBaseContext(), CameraDefectActivity.class);   
        	    startActivity(newActivity);
        	   
			}
		});

	}
    
}
